from copy import copy


class Solution:

    def __init__(self, st):
        self._sp = st.split()
        self._sl = {'zero': 0, 'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5, 'six': 6, 'seven': 7, 'eight': 8, 'nine': 9}

    @staticmethod
    def simply_number(ch):
        k = 0
        for i in range(2, ch // 2 + 1):
            if ch % i == 0:
                k += 1
        if k <= 0:
            return True
        return False

    def to_int(self):
        try:
            st = ''
            for ch in self._sp:
                st += str(self._sl[ch])
            return int(st)
        except:
            raise ValueError('Wrong input')

    def result(self):
        res_plus = copy(self.to_int())
        res_minus = copy(self.to_int())
        while self.simply_number(res_plus) == False:
            res_plus += 1
        while self.simply_number(res_minus) == False:
            res_minus -= 1
        if self.to_int() - res_minus < res_plus - self.to_int():
            return res_minus
        return res_plus


st = input()
exmp = Solution(st)
print(exmp.result())


